import { ActionTypes, AssetImages, HttpAPI } from '../constants'
import { AxiosUtil } from '../utils'
import base from './base'
const getPetById = 'pet/select'
const getPetList = 'pet/select/user'
const updatePetInfo = 'pet/update'
const addPet = 'pet/add'
const deltePet = 'pet/delete'
const relatePet = 'pet/addrelate'
const removeRelate = 'pet/delrelate'

export default {
    fetchPetInfoById: function * (payload) {
        const { data, callBack = null } = payload;
        const { response, error } = yield AxiosUtil.get(getPetById, data)
        yield base.after(response, error, ActionTypes.API_GET_PET_INFO_BY_PET_ID_SUCCESS)
        callBack && callBack(response, error)
    },
    fetchPetListByUser: function * (payload) {
        const { data, callBack = null } = payload;
        const { response, error } = yield AxiosUtil.get(getPetList, data)
        yield base.after(response, error, ActionTypes.API_GET_PETS_BY_USER_ID_SUCCESS)
        callBack && callBack(response, error)
    },
    fetchUpdatePetInfo: function * (payload) {
        const { data, callBack = null } = payload;
        const { response, error } = yield AxiosUtil.get(updatePetInfo, data)
        yield base.after(response, error, ActionTypes.API_GET_PET_INFO_BY_PET_ID_SUCCESS)
        callBack && callBack(response, error)
    },
    fetchAddPet: function * (payload) {
        const { data, callBack = null } = payload;
        const { response, error } = yield AxiosUtil.get(addPet, data)
        yield base.after(response, error, ActionTypes.API_ADD_PET_SUCCESS)
        callBack && callBack(response, error)
    },
    fetchDelPet: function * (payload) {
        const { data, callBack = null } = payload
        const { response, error } = yield AxiosUtil.get(deltePet, data)
        yield base.after(response, error, ActionTypes.API_DELETE_PET_SUCCESS)
        callBack && callBack(response, error)
    },
    fetchAddRelate: function * (payload) {
        const { data, callBack = null } = payload;
        const { response, error } = yield AxiosUtil.get(relatePet, data)
        yield base.after(response, error, ActionTypes.API_RELATE_WITH_PET_SUCCESS)
        callBack && callBack(response, error)
    },
    fetchDelRelate: function * (payload) {
        const { data, callBack = null } = payload;
        const { response, error } = yield AxiosUtil.get(removeRelate, data)
        yield base.after(response, error, ActionTypes.API_REMOVE_RELATE_WITH_PET_SUCCESS)
    }
    // getVideoList: function* (payload) {
    //     const { response, error } = yield AxiosUtil.get(homeList);
    //     console.log('getVideoList', response, error);
    //     yield base.after(response, error, ActionTypes.API_GET_VIDEO_LIST_SUCCESS)
    // }
}